// stores/counter.js
import { defineStore } from 'pinia'
import { v4 as uuidv4 } from 'uuid'

interface State {
  count: number;
}

export interface EditorProps {
  components: ComponentData[];
  currentElement: string;
}



interface ComponentData {
  props: {
    // eslint-disable-next-line
    [key: string]: any;
  };
  id: string;
  // 业务组件库名称 l-text， 等
  name: string;
}


export const testComponents: ComponentData[] = [
  {
    id: uuidv4(),
    name: 'l-text',
    props: {
      text: 'hello',
      fontSize: '20px',
      color: '#000000',
      lineHeight: '1',
      textAlign: 'left',
      fontFamily: ''
    }
  },
  {
    id: uuidv4(),
    name: 'l-text',
    props: {
      text: 'hello2',
      fontSize: '10px',
      fontWeight: 'bold',
      lineHeight: '2',
      textAlign: 'left',
      fontFamily: ''
    }
  },
  {
    id: uuidv4(),
    name: 'l-text',
    props: {
      text: 'hello3',
      fontSize: '15px',
      actionType: 'url',
      url: 'https://www.baidu.com',
      lineHeight: '3',
      textAlign: 'left',
      fontFamily: '',
      isEditing: true,
      cursor: 'pointer'
    }
  }
]


export const useEditStore = defineStore('edit', {
  state: <EditorProps>() => {
    return { 
      components: testComponents,
      currentElement: ''
     }
  },
  // 也可以这样定义
  // state: () => ({ count: 0 })
  actions: {
    increment() {
      this.currentElement = 'jjj'
    },
  },
})